package com.glory.wxelectricitypda.adapter;

import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.wxelectricitypda.R;
import com.glory.wxelectricitypda.bean.ScrapBean;
import com.pda.platform.ui.ui_pdaplatform.view.FreeUI_ClearEditText;

import java.util.List;


public class ScrapListAdapter extends BaseQuickAdapter<ScrapBean, BaseViewHolder> {

    public ScrapListAdapter(@Nullable List<ScrapBean> data) {
        super(R.layout.adapter_scrap_list, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, final ScrapBean item) {
        if (item.getDESCRIPTION().contains("其他")) {
            helper.setText(R.id.tvName, "其他");
        } else {
            helper.setText(R.id.tvName, item.getDESCRIPTION());
        }
        FreeUI_ClearEditText etNum = helper.getView(R.id.etNum);
        etNum.setText(item.getQTY());
        FreeUI_ClearEditText etRemark = helper.getView(R.id.etRemark);
        etRemark.setText(item.getCOMMENTS());
        etNum.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                item.setQTY(charSequence.toString());
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

        etRemark.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                item.setCOMMENTS(charSequence.toString());
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }
}
